package com.leenmvc.core.dao.iotdb.connect;

import org.apache.iotdb.session.pool.SessionPool;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: JohnCoding
 * @Description:  管理IOTDB数据源
 * @date: 2020/6/1 9:21
 */
@Configuration
public class IotDBConfig {

    @Value("${iotdb.username}")
    private String username;

    @Value("${iotdb.password}")
    private String password;

    @Value("${iotdb.ip}")
    private String ip;

    @Value("${iotdb.port}")
    private Integer port;

    @Value("${iotdb.maxSize}")
    private Integer maxSize;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public Integer getMaxSize() {
        return maxSize;
    }

    public void setMaxSize(Integer maxSize) {
        this.maxSize = maxSize;
    }

    /**
     * IOTDB数据源配置
     *
     * @return
     */
    @Bean
    public SessionPool dataSourceE() {
        SessionPool sessionPool = new SessionPool(ip, port,username, password, maxSize);
        return sessionPool;
    }
}
